﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SchoolManagementSystem
{
    public partial class Graduate : Form
    {
        public Graduate()
        {
            InitializeComponent();
        }

        public Graduate(string id, string name)
        {
            InitializeComponent();
            txtID.Text = id;
            txtName.Text = name;
        }

        public string Year { get { return txtYear.Text; } }
        public string School { get { return txtSchool.Text; } }
        public string Description { get { return txtDescription.Text; } }

        private void btnSimpan_Click(object sender, EventArgs e)
        {
            if (txtYear.Text.Length == 0 || txtSchool.Text.Length == 0 || txtDescription.Text.Length == 0)
            {
                MessageBox.Show("Mohon lengkapi semua data", "Peringatan!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                int.Parse(txtYear.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data tahun hanya menerima input angka saja", "Peringatan!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnYear_Click(object sender, EventArgs e)
        {
            txtYear.Text = DateTime.Now.Year.ToString();
        }

        private void btnBatal_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
